﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BusLib
{
    public partial class Pattern_Pair
    {
        public static Pattern_Pair ImportCSV(string line)
        {
            Pattern_Pair pp = new Pattern_Pair();
            string[] fields = line.Split(',');
            pp.Route_1 = Route.GetRouteByNumber(int.Parse(fields[0]));
            pp.Route_2 = Route.GetRouteByNumber(int.Parse(fields[1]));
            if (fields[2] != "")
            {
                pp.stop_id = int.Parse(fields[2]);
            }
            pp.shape_id_1 = int.Parse(fields[3]);
            pp.shape_id_2 = int.Parse(fields[4]);

            BusLibDataContext db = BusLibDataContext.db;
            db.Pattern_Pairs.InsertOnSubmit(pp);
            db.SubmitChanges();

            return pp;
        }
    }
}
